/* 模块工具，专注于编写需要用到的工具 */
import { Notification,Message } from 'element-ui';

/**
 * 打开消息通知框
 */
export function openNotify(state,context,type='notity'){
	state = state-1;
	/* 弹出框状态映射 */
	let notityType =[
		{title:"成功",type:"success"},
		{title:"警告",type:"warning"},
		{title:"错误",type:"error"},
		{title:"消息",type:"info"}]
	
	/* 如果传入的参数不符合给出的 notityType 设置的数据，设置默认值为 "消息" 提示框 */
	if(state<0 || state>=notityType.length){state = 3}
	
	if(type=='notity'){
		/* 弹出对应的对话框 */
		Notification({
			title: notityType[state].title,
			message: context,
			type: notityType[state].type,
			dangerouslyUseHTMLString: true
		})
	}else{
		/* 弹出消息框 */
		Message({
			title: notityType[state].title,
			message: context,
			type: notityType[state].type,
			dangerouslyUseHTMLString: true,
			showClose:true,
		})
	}	
}